<?php

namespace addons\helper\controller\wxapp;

use addons\helper\controller\wxapp\Base;
use fast\Random;

class Dashboard extends Base
{
    public function index()
    {
        $seventtime = \fast\Date::unixtime('day', -7);
        $paylist = $createlist = $commentList = [];
        for ($i = 0; $i < 7; $i++)
        {
            $day = date("m-d", $seventtime + ($i * 86400));
            $createlist[$day] = mt_rand(20, 200);
            $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
            $commentList[$day] = Random::nozero(3);
        }
        $tabList = ['会员统计','文章统计','评论统计'];
        $categoryList = model('app\common\model\Category')->getCategoryArray();
        $articleList = [];
        foreach ($categoryList as $k => $v) {
            $articleList[$k]['value'] = Random::nozero(3);
            $articleList[$k]['name'] = $v['name'];
        }
        $userAreaValue = [];
        for ($i=0; $i < 10; $i++) { 
            $userAreaValue[] = Random::nozero(2);
        }
        rsort($userAreaValue);
        $userAreaList = ['北京', '上海', '广东', '浙江', '四川', '重庆', '湖北', '河北', '湖南', '江苏' ];
        shuffle($userAreaList);
        $data = [
            'tabList'          => $tabList,
            'totaluser'        => 35200,
            'totalviews'       => 219390,
            'totalorder'       => 32143,
            'totalorderamount' => 174800,
            'totalprofit'      => 98738,
            'totalcategory'    => 39,
            'totalattachment'  => 3988,
            'todayuserlogin'   => 321,
            'todayusersignup'  => 430,
            'todayorder'       => 2324,
            'unsettleorder'    => 132,
            'sevendnu'         => '80%',
            'sevendau'         => '32%',
            'paylist'          => $paylist,
            'createlist'       => $createlist,
            'userAreaList'     => $userAreaList,
            'userAreaValue'    => $userAreaValue,
            'articleList'      => $articleList,
            'commentList'      => $commentList
            
        ];
        $this->success('ok', $data);

        return $this->view->fetch();
    }

}
